from DistributionCenter import DistributionCenter
from utils import time_now, time_increment, get_cost

if __name__ == '__main__':
    dc = DistributionCenter(10, 10)
    dc.calculate_distance_matrix()
    dc.draw_fig()

    duration = 12 * 60
    while time_now() <= duration:
        dc.update_orders()

        dc.decision_making()

        # print(f"时刻：{time_now()}")
        # for path in dc.finished_paths[time_now()]:
        #     print(f"\t总长度：{path.min_mileage}，订单数：{path.orders_num}，"
        #           f"经过卸货点个数：{len(path.traverse_order) - 2}个，"
        #           f"路径：{path.traverse_order[1:-1]}，订单{path.orders_list}")

        time_increment()
    dc.draw_fig_with_path(dc.finished_paths[600])

    print(f'worst: {get_cost()[0]}, improved: {get_cost()[1]}, rate: {1-get_cost()[1]/get_cost()[0]}')